package com.bjpowernode.controller;

import com.bjpowernode.common.result.Result;
import com.bjpowernode.service.DicService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequiredArgsConstructor
public class DicController {

    private final DicService dicService;

    //根据字典类型获得字典数据
    @GetMapping("/api/dic/{type}")
    public Result getDicByType(@PathVariable("type") String type) {
        if (type == null || type.isEmpty()) {
            return Result.FAIL("字典类型不能为空");
        }
        return Result.OK(dicService.getDicByType(type));
    }
}
